//
//  ChangeNameViewController.m
//  wtshoppingcite
//
//  Created by TW on 14-12-8.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "ChangeNameViewController.h"

@interface ChangeNameViewController ()<UITextFieldDelegate>

@end

@implementation ChangeNameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTitleView:@"更换昵称"];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
    [self.view addGestureRecognizer:tap];
    
    _textField.delegate = self;

}

-(IBAction)confirmAction:(id)sender{
    
    if (_textField.text == nil || [_textField.text  isEqual: @""]) {
         [self showToastMessage:@"请输入新的昵称"];
    }else{
        if (self.delegate && [self.delegate respondsToSelector:@selector(changeName:)]) {
            
            [self.delegate changeName:self.textField.text];
        }
        
        [self.navigationController popViewControllerAnimated:YES];
        
    }
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [_textField resignFirstResponder];
    return YES;
}

-(void)tapAction{
    
    [_textField resignFirstResponder];
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    ;
}


- (void)viewWillDisappear:(BOOL)animated
{
    
    [super viewWillDisappear:animated];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
